package fhp.hlhj.giantfold.adapter

import android.content.Context
import android.support.v4.view.PagerAdapter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import com.bumptech.glide.Glide
import fhp.hlhj.giantfold.R
import fhp.hlhj.giantfold.javaBean.AdvBean
import fhp.hlhj.giantfold.network.Urls
import java.util.ArrayList

/**
 * Created by Administrator on 2018\2\26 0026.
 */
class LoginPagerAdp(private val context: Context,private val datas:ArrayList<AdvBean.DataBean>) :PagerAdapter() {

    override fun instantiateItem(container: ViewGroup?, position: Int): Any {
        val view = LayoutInflater.from(context).inflate(R.layout.login_pager_item, null)
        val img = view.findViewById<ImageView>(R.id.img)
        when(position){
            0->{
                Glide.with(context).load(R.mipmap.start_1).dontAnimate().into(img)
            }
            1->{
                Glide.with(context).load(R.mipmap.start_2).dontAnimate().into(img)
            }
        }
//        Glide.with(context).load(Urls.BaseUrl+datas[position].adv_img).dontAnimate().into(img)
        container?.addView(view)
        return view
    }
    override fun isViewFromObject(p0: View?, p1: Any?): Boolean {
        return p0==p1
    }

    override fun getCount(): Int {
        return 2
    }

    override fun destroyItem(container: ViewGroup?, position: Int, `object`: Any?) {
//        super.destroyItem(container, position, `object`)
    }
}
